package com.cy;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/consumer/feign/")
public class FeignConsumerController {

    @Value("${spring.application.name}")
    private String appname;

    @Autowired
    private ConsumerFeignApi consumerFeignApi;

    @Autowired
    private ConsumerService consumerService;

    //http://localhost:8090/consumer/feign/echo/
    @GetMapping("/echo/")
    public String echoMsg(){

        consumerService.doGetResource();

        //测试接口实现类的获取
        System.out.println("consumerFeignApi="+consumerFeignApi.getClass().getName());

        //基于feign实现远程过程调用
        return consumerFeignApi.echoMsg(appname)+"Feign";
    }
}
